﻿Imports System.Data.SqlClient
Public Class clsOtrosCargos
    Private mintidCargo As Integer
    Private mintidEmpleado As Integer
    Private mstrMotivo As String
    Private mdblMonto As Double
    Private mintTiempo As Integer
    Private mstrTipo As String
    Private mdblDescuento As Double
    Private mstrCapturo As String
    Private mstrReportado As String
    Private mdatFecha As Date
    Private mdatFechaRegistro As Date

    Public Property idCargo() As Integer
        Get
            Return mintidCargo
        End Get
        Set(ByVal value As Integer)
            mintidCargo = value
        End Set
    End Property
    Public Property idempleado() As Integer
        Get
            Return mintidEmpleado
        End Get
        Set(ByVal value As Integer)
            mintidEmpleado = value
        End Set
    End Property
    Public Property Motivo() As String
        Get
            Return mstrMotivo
        End Get
        Set(ByVal value As String)
            mstrMotivo = value
        End Set
    End Property
    Public Property Monto() As Double
        Get
            Return mdblMonto
        End Get
        Set(ByVal value As Double)
            mdblMonto = value
        End Set
    End Property
    Public Property Tiempo() As Integer
        Get
            Return mintTiempo
        End Get
        Set(ByVal value As Integer)
            mintTiempo = value
        End Set
    End Property
    Public Property Tipo() As String
        Get
            Return mstrTipo
        End Get
        Set(ByVal value As String)
            mstrTipo = value
        End Set
    End Property
    Public Property Descuento() As Double
        Get
            Return mdblDescuento
        End Get
        Set(ByVal value As Double)
            mdblDescuento = value
        End Set
    End Property
    Public Property Capturo() As String
        Get
            Return mstrCapturo
        End Get
        Set(ByVal value As String)
            mstrCapturo = value
        End Set
    End Property
    Public Property Reportado() As String
        Get
            Return mstrReportado
        End Get
        Set(ByVal value As String)
            mstrReportado = value
        End Set
    End Property
    Public Property fecha() As Date
        Get
            Return mdatFecha
        End Get
        Set(ByVal value As Date)
            mdatFecha = value
        End Set
    End Property
    Public Property FechaRegistro() As Date
        Get
            Return mdatFechaRegistro
        End Get
        Set(ByVal value As Date)
            mdatFechaRegistro = value
        End Set
    End Property
    Public Sub New()
        mintidCargo = 0
        mintidEmpleado = 0
        mstrMotivo = ""
        mdblMonto = 0
        mintTiempo = 1
        mstrTipo = ""
        mdblDescuento = 0
        mstrCapturo = ""
        mstrReportado = ""
        mdatFecha = Now()
        mdatFechaRegistro = Now()
    End Sub
    Public Sub Borrar()
        Call SetSqlCitra("Delete From OtrosCargos Where idCargo= " & idCargo)

    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into OtrosCargos (" & _
                            "IdCargo," & _
                            "IdEmpleado," & _
                            "Motivo," & _
                            "Monto," & _
                            "Tiempo," & _
                            "Tipo," & _
                            "Descuento," & _
                            "Capturo," & _
                            "Reportado," & _
                            "Fecha," & _
                            "FechaRegistro)" & _
                            "VALUES (" & _
                            "@IdCargo," & _
                            "@IdEmpleado," & _
                            "@Motivo," & _
                            "@Monto," & _
                            "@Tiempo," & _
                            "@Tipo," & _
                            "@Descuento," & _
                            "@Capturo," & _
                            "@Reportado," & _
                            "@Fecha," & _
                            "@FechaRegistro)"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdCargo", mintidCargo)
        Command.Parameters.AddWithValue("IdEmpleado", mintidEmpleado)
        Command.Parameters.AddWithValue("Motivo", mstrMotivo)
        Command.Parameters.AddWithValue("Monto", mdblMonto)
        Command.Parameters.AddWithValue("Tiempo", mintTiempo)
        Command.Parameters.AddWithValue("Tipo", mstrTipo)
        Command.Parameters.AddWithValue("Descuento", mdblDescuento)
        Command.Parameters.AddWithValue("Capturo", mstrCapturo)
        Command.Parameters.AddWithValue("Reportado", mstrReportado)
        Command.Parameters.AddWithValue("Fecha", mdatFecha)
        Command.Parameters.AddWithValue("FechaRegistro", mdatFechaRegistro)


        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el registro ", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
